#include "aghFib.h"

using namespace std;

int & aghFib::operator[](int el)
{
	this->num = countFib(el); 
	return this->num;
}

int aghFib::countFib(int pos)
{
	if(pos<=0)return 0;
	if(pos==1 || pos==2)return 1;
	int res=1,less1=1,less2=1;
	for(int i=3;i<=pos;++i)
	{
		res = less1+less2;
		less2=less1;
		less1=res;
	}
	return res;
}